﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.InterferenceVolumeQuery.IVQTreeListModel
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.InterferenceVolumeQuery.Tree;
using System.Collections;


namespace DnProcessSimulateCommands.InterferenceVolumeQuery;

internal class IVQTreeListModel : ITreeModel
{
  private int j;

  private IIVQTreeViewItem root { get; set; }

  public IVQTreeListModel() => this.root = (IIVQTreeViewItem) new IVQTreeItem();

  public IIVQTreeViewItem CreateTreeViewItem()
  {
    IIVQTreeViewItem treeViewItem = (IIVQTreeViewItem) new IVQTreeItem();
    IIVQTreeViewItem[] ivqTreeViewItemArray1 = (IIVQTreeViewItem[]) new IVQTreeItem[2];
    IIVQTreeViewItem[] ivqTreeViewItemArray2 = (IIVQTreeViewItem[]) new IVQTreeItem[2];
    IIVQTreeViewItem[] ivqTreeViewItemArray3 = (IIVQTreeViewItem[]) new IVQTreeItem[2];
    IIVQTreeViewItem[] ivqTreeViewItemArray4 = (IIVQTreeViewItem[]) new IVQTreeItem[4];
    for (int index = 0; index < 4; ++index)
    {
      ivqTreeViewItemArray4[index] = (IIVQTreeViewItem) new IVQTreeItem();
      ivqTreeViewItemArray4[index].IVQName = this.j.ToString();
      ++this.j;
    }
    for (int index = 0; index < 2; ++index)
    {
      ivqTreeViewItemArray1[index] = (IIVQTreeViewItem) new IVQTreeItem();
      ivqTreeViewItemArray1[index].IVQName = "Swept Volume: " + this.j.ToString();
      ++this.j;
      ivqTreeViewItemArray2[index] = (IIVQTreeViewItem) new IVQTreeItem();
      ivqTreeViewItemArray2[index].IVQName = "Robot: " + this.j.ToString();
      ++this.j;
      ivqTreeViewItemArray3[index] = (IIVQTreeViewItem) new IVQTreeItem();
      ivqTreeViewItemArray3[index].IVQName = "Operation Program: " + this.j.ToString();
      ++this.j;
    }
    treeViewItem.IVQName = "Interference volume: " + this.j.ToString();
    ++this.j;
    ivqTreeViewItemArray3[0].Children.Add(ivqTreeViewItemArray4[0]);
    ivqTreeViewItemArray3[0].Children.Add(ivqTreeViewItemArray4[1]);
    ivqTreeViewItemArray3[1].Children.Add(ivqTreeViewItemArray4[2]);
    ivqTreeViewItemArray3[1].Children.Add(ivqTreeViewItemArray4[3]);
    ivqTreeViewItemArray1[0].Children.Add(ivqTreeViewItemArray2[0]);
    ivqTreeViewItemArray1[0].Children.Add(ivqTreeViewItemArray3[0]);
    ivqTreeViewItemArray1[1].Children.Add(ivqTreeViewItemArray2[1]);
    ivqTreeViewItemArray1[1].Children.Add(ivqTreeViewItemArray3[1]);
    treeViewItem.Children.Add(ivqTreeViewItemArray1[0]);
    treeViewItem.Children.Add(ivqTreeViewItemArray1[1]);
    return treeViewItem;
  }

  public IEnumerable GetChildren(object parent)
  {
    IIVQTreeViewItem ivqTreeViewItem = parent as IIVQTreeViewItem;
    if (parent == null)
      parent = (object) this.root;
    return (IEnumerable) (parent as IIVQTreeViewItem).Children;
  }

  public bool HasChildren(object parent)
  {
    return parent is IIVQTreeViewItem ivqTreeViewItem && ivqTreeViewItem.Children != null && ivqTreeViewItem.Children.Count > 0;
  }

  public object RootNode => (object) this.root;
}
